<template>
	 
 <view class="goods-item" >
	<radio  v-if="show" :checked="goods.goods_state" color="#C00000" @click="radioClick(goods)"> </radio>
 	<view class="goods-item-left">
 		<image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image>
 	</view>
 	<view class="goods-item-right">
 		 <text class="goods-name" @click="passGoodsdailte(goods.goods_id)">{{goods.goods_name}}</text>
		 <view class="right-bottm">
		<text class="goods-price">￥{{goods.goods_price | tofixed}}</text>	 
		<uni-number-box min="1" :value="goods.goods_count" v-if="show" @change="numChange"></uni-number-box>
		 </view>
 		 
 	</view>
 </view>
</template>

<script>
  export default {
    props: {
      goods: {
        type: Object,
        default: {}
      },
	  show: {
	    type: "",
	    default: false
	  }
	       
     
    },
    data() {
      return {
        // 默认的图片
       defaultPic:"https://tukuimg.bdstatic.com/scrop/96b3f9818e299dfef113d0551c9bab08.gif"
      };
    },
	filters:{
		tofixed(num){
		
			return Number(num).toFixed(2)
		}
	},
	methods:{
		radioClick(e){
			 let CartItem={
				 goods_state:!e.goods_state,
				 goods_id:e.goods_id
			 }
			uni.$Store.commit("REVISE",CartItem)
			uni.setStorageSync("cart",uni.$Store.state.cartdata.cart)
		},
		passGoodsdailte(item){
			
			uni.navigateTo({
				url:"/subpkg/goods_detail/goods_detail?goods_id="+item
			})
		},
		numChange(val){
			// console.log(val)
			// console.log(this.goods.goods_id)
			 var revise={
				 goods_id:this.goods.goods_id,
				 goods_count:+val
			 }
			uni.$Store.commit("passNum",revise)
			uni.setStorageSync("cart", uni.$Store.state.cartdata.cart)
			this.$emit("cartCheck")
		}
	},


  }
</script>

<style lang="scss">
  .goods-item {
    width: 750rpx;
    box-sizing: border-box;
    display: flex;
    padding: 10px 5px;
    border: 1px solid #f0f0f0;
    align-items: center;
	
    .goods-item-left {
      .goods-pic {
        width: 100px;
        height: 100px;
        display: block;
      }
	 
    }

    .goods-item-right {
      display: flex;
	   height: 100px;
	  // width:00px;
      // flex: 1;
      flex-direction: column;
      justify-content: space-between;
      padding-left:5px;
      .goods-name {
        font-size: 12px;
      }

    .right-bottm{
		width: 480rpx;
    		  display:flex;
    		  justify-content: space-between;
			  align-items: center;
			  .goods-price {
			    color: #C00000;
			    font-size: 16px;
			  }
    }
       
     
    }
  }
</style>
